<!---
	* Author: Cristian Costantini 
	* License: http://www.apache.org/licenses/LICENSE-2.0
	 --->
	 
<cfsetting enablecfoutputonly="true">

<cfparam name="attributes.format" default="png" />

<cfif thisTag.ExecutionMode eq "end">
	<cfexit>
</cfif>

<div align="center">
	
<h1>Cache monitor</h1>

<cfset cacheobjects = attributes.cacheManager.getCacheNames() />

<cfswitch expression="#attributes.format#">
	
	<cfcase value="png">
	
		<cfloop array="#cacheobjects#" index="c">
			
			<cfset s = attributes.cacheManager.getStatistics( c ) />
			
			<cfchart format="png" title="#s.getCacheName()#" show3D="true" chartheight="300" chartwidth="400" showborder="true">
				<cfchartseries type="bar" colorlist="##00FF00,##CC0000,##CCFF00,##FF0000,##CC0099,##0000FF,##FFFF66,##FFFFFF">
					<cfchartdata item="Object count" value="#s.getObjectCount()#" />
					<cfchartdata item="Hits" value="#s.getCacheHits()#">
					<cfchartdata item="Hits on disk" value="#s.getOnDiskHits()#" />
					<cfchartdata item="Hits in memory" value="#s.getInMemoryHits()#" />
					<cfchartdata item="Misses" value="#s.getCacheMisses()#">
			        <cfchartdata item="Average time" value="#s.getAverageGetTime()#">
			        <cfchartdata item="Disk Object" value="#s.getDiskStoreObjectCount()#">
			        <cfchartdata item="Memory object" value="#s.getMemoryStoreObjectCount()#">
				</cfchartseries>
			</cfchart>
		
		</cfloop>
		
	</cfcase>

	<cfcase value="html">
		
		<cfoutput>
		<style type="text/css">
		.tablelisting{
			background-color: ##CDCDCD;
			margin:10px 0pt 15px;
			border-spacing: 1px;
		}
		.tablelisting tr{
			background-color: ##F7F7F7;
		}
		.tablelisting tr.even{
			background-color: ##ffffff;
		}
		.tablelisting tr:hover { background: ##d7eafe}
		.tablelisting th {
			text-align: left;
			background-color: ##E0EFEF;
			padding: 4px;
		}
		.tablelisting th.center{
			text-align:center;
		}
		.tablelisting th a {
			color: ##000;
			background-color: inherit;
			text-decoration: none;
			border-bottom: none;
		}
		.tablelisting th a:hover {
			color: ##CC0001; 
			background-color: inherit;	
		}
		.tablelisting td{
			padding: 5px;
		}
		.tablelisting td.center{
			text-align: center;
		}
		.tablelisting a {
			text-decoration: none;
			border-bottom: none;
		}
		.tablelisting a:hover {
			color: ##CC0001; 
			background-color: inherit;	
		}
		</style>		
		</cfoutput>

		<cfloop array="#cacheobjects#" index="c">
			
			<cfset s = attributes.cacheManager.getStatistics( c ) />
			
			<cfoutput>			
				<h2>#s.getCacheName()#</h2>	
				<table class="tablelisting">
					<tr>
						<th>Object count</th>
						<th>Hits</th>
						<th>Hits on disk</th>
						<th>Hits in memory</th>
						<th>Misses</th>
				        <th>Average time</th>
				        <th>Disk Object</th>
				        <th>Memory object</th>
					</tr>
					<tr>
						<td align="center">#s.getObjectCount()#</td>
						<td align="center">#s.getCacheHits()#</td>
						<td align="center">#s.getOnDiskHits()#</td>
						<td align="center">#s.getInMemoryHits()#</td>
						<td align="center">#s.getCacheMisses()#</td>
				        <td align="center">#s.getAverageGetTime()#</td>
				        <td align="center">#s.getDiskStoreObjectCount()#</td>
				        <td align="center">#s.getMemoryStoreObjectCount()#</td>				
					</tr>
				</table>
			</cfoutput>		
		</cfloop>
			
	</cfcase>

</cfswitch>

</div>

<cfsetting enablecfoutputonly="false">
